package com.example.springboottools.utils.staples.test;

import cn.hutool.http.webservice.SoapClient;
import com.example.springboottools.utils.ReadExcel;

import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import java.io.File;
import java.util.List;
import java.util.Map;

public class SendWebServiceUtils {

    public static void main(String[] args) throws SOAPException {
//        SoapClient soapClient = SoapClient.create("http://newvp.staplescn.com/ServiceCenter-VPServer/ws/feedbackService?wsdl")
//                .setMethod("feed:feedback","http://feedback.ws.mdm.staples.com/");
//        // 创建SoapClient对象
//      /*  SoapClient soapClient = SoapClient.create("http://10.10.5.223:9999/ServiceCenter-VPServer/ws/receiveSapPoStatus?wsdl")
//                .setMethod("ser:receiveSapPoStatus","http://service.webservice.staples.com/");*/
//        String excelPath = "D:\\staples\\日常记录\\工作记录\\2024\\06\\05\\缺失sapsku回推.xls";
//        File excelFile = new File(excelPath);
//        String[] nameStr = {"SKU","ext1"};
//        List<Map<String, Object>> excelMapList = ReadExcel.readExcel1(excelFile, nameStr, 1, 0);
//        excelMapList.forEach(
//                map -> {
//                    String ext1 = map.get("ext1").toString();
//                    try {
//                        SOAPElement params = soapClient.getMethodEle().addChildElement("arg0");
//
//                        params.addChildElement("messageId").setValue(ext1);
//                        params.addChildElement("status").setValue("S");
//                        System.out.println(soapClient.send(true));
//                    } catch (SOAPException e) {
//                        throw new RuntimeException(e);
//                    }
//                }
//        );



        sendPoStatusTest();

            }




    /**
     * 推送PO开票，核销单状态
     * @throws SOAPException
     */

    public static void sendPoStatusTest() throws SOAPException {

        // 创建SoapClient对象
        SoapClient soapClient = SoapClient.create("http://localhost:8081/ServiceCenter_VPServer/ws/receiveSapPoStatus?wsdl")
                .setMethod("ser:receiveSapPoStatus","http://service.webservice.staples.com/");
/*        SoapClient soapClient = SoapClient.create("http://newvp.staplescn.com/ServiceCenter-VPServer/ws/receiveSapPoStatus?wsdl")
                .setMethod("ser:receiveSapPoStatus","http://service.webservice.staples.com/");*/
        // 创建SoapClient对象
      /*  SoapClient soapClient = SoapClient.create("http://10.10.5.223:9999/ServiceCenter-VPServer/ws/receiveSapPoStatus?wsdl")
                .setMethod("ser:receiveSapPoStatus","http://service.webservice.staples.com/");*/
        SOAPElement params = soapClient.getMethodEle().addChildElement("params");
//        for (int i = 0; i < 10; i++) {
//          /*  SOAPElement clearInfoList = params.addChildElement("clearInfoList");
//            clearInfoList.addChildElement("EBELN").setValue(getValue(i));
//            clearInfoList.addChildElement("BUKRS").setValue("4500815098");
//            clearInfoList.addChildElement("VBELN").setValue("4500815098");
//            clearInfoList.addChildElement("ZHXDAT").setValue("4500815098");
//            clearInfoList.addChildElement("ZHXTIM").setValue("4500815098");
//            clearInfoList.addChildElement("ZHXZT").setValue("4500815098");
//            SOAPElement invoicingInfoList = params.addChildElement("invoicingInfoList");
//            invoicingInfoList.addChildElement("BUKRS").setValue("");
//            invoicingInfoList.addChildElement("EBELN").setValue(getValue(i));
//            invoicingInfoList.addChildElement("VBELN").setValue("");
//            invoicingInfoList.addChildElement("ZKPDAT").setValue("");
//            invoicingInfoList.addChildElement("ZKPTIM").setValue("");
//            invoicingInfoList.addChildElement("ZKPZT").setValue("");*/
//
//        }
        //合作伙伴开票状态
/*        SOAPElement poInvoicingInfoList1 = params.addChildElement("poInvoicingInfoList");
        poInvoicingInfoList1.addChildElement("EBELN").setValue("4506974298");
        poInvoicingInfoList1.addChildElement("BELNR").setValue("5105611082");
        poInvoicingInfoList1.addChildElement("GJAHR").setValue("2024");
        poInvoicingInfoList1.addChildElement("BUKRS").setValue("3150");
        poInvoicingInfoList1.addChildElement("ZPOKPZT").setValue("40");
        poInvoicingInfoList1.addChildElement("ZPOKPDAT").setValue("20240730");
        poInvoicingInfoList1.addChildElement("ZPOKPTIM").setValue("150546");*/
        SOAPElement poInvoicingInfoList1 = params.addChildElement("clearInfoList");
        poInvoicingInfoList1.addChildElement("EBELN").setValue("4506974298");
        poInvoicingInfoList1.addChildElement("BUKRS").setValue("5105611082");
        poInvoicingInfoList1.addChildElement("VBELN").setValue("2024");
        poInvoicingInfoList1.addChildElement("ZHXZT").setValue("3150");
        poInvoicingInfoList1.addChildElement("ZHXDAT").setValue("40");
        poInvoicingInfoList1.addChildElement("ZHXTIM").setValue("20240730");
        poInvoicingInfoList1.addChildElement("ZSOZBJ").setValue("0.00");
        poInvoicingInfoList1.addChildElement("ZSOZBJHK").setValue("150546");
//        SOAPElement poInvoicingInfoList = params.addChildElement("poInvoicingInfoList");
//        poInvoicingInfoList.addChildElement("EBELN").setValue("4500692774");
//        poInvoicingInfoList.addChildElement("BELNR").setValue("");
//        poInvoicingInfoList.addChildElement("GJAHR").setValue("");
//        poInvoicingInfoList.addChildElement("BUKRS").setValue("3071");
//        poInvoicingInfoList.addChildElement("ZPOKPZT").setValue("30");
//        poInvoicingInfoList.addChildElement("ZPOKPDAT").setValue("20230616");
//        poInvoicingInfoList.addChildElement("ZPOKPTIM").setValue("112323");
        System.out.println(soapClient.send(true));
    }

}
